package com.zhuhjay.service.system.model.vo;

import com.zhuhjay.common.base.util.BeanBuilder;
import com.zhuhjay.common.base.util.BigDecimalUtils;
import com.zhuhjay.service.system.model.entity.SystemPicture;
import lombok.Data;

import java.util.Date;

/**
 * @author ZhuHJay
 * @date 2023/6/19 23:23
 */
@Data
public class PictureVo {

    private String id;
    private String realName;
    private String filePath;
    private String size;
    private String origin;
    private String createUser;
    private Date createTime;

    public static PictureVo of(SystemPicture picture, String username) {
        return BeanBuilder.builder(PictureVo::new)
                .with(PictureVo::setId, picture.getId().toString())
                .with(PictureVo::setRealName, picture.getRealName())
                .with(PictureVo::setFilePath, picture.getFilePath())
                .with(PictureVo::setSize, BigDecimalUtils.byte2Kb(picture.getSize()) + "KB")
                .with(PictureVo::setOrigin, picture.getOrigin())
                .with(PictureVo::setCreateUser, username)
                .with(PictureVo::setCreateTime, picture.getCreateTime())
                .build();
    }

}
